package com.albaba.nacosconfig.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description: TODO
 * @Author zx
 * @Date 2024/12/21 15:21
 * @Version 1.0
 */
@RestController
@RefreshScope // 动态刷新配置
public class NacosConfigPublicController {

    // 通用配置
    @Value("${config.common}")
    private String configCommon;

    @Value("${spring.redis.host}")
    private String redisHost;

    @Value("${spring.datasource.mysql.url}")
    private String mysqlUrl;

    @GetMapping(value = "/config/common")
    public String getConfigCommon() {
        return configCommon;
    }

    @GetMapping(value = "/config/redis")
    public String getConfigRedis() {
        return redisHost;
    }

    @GetMapping(value = "/config/mysql")
    public String getConfigMysql() {
        return mysqlUrl;
    }

}
